<!--
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author YDZ
-->
<template>
  <BasicDrawer
    v-bind="$attrs"
    :showFooter="false"
    :okAuth="'process:meter:pmWatermeter:edit'"
    @register="registerDrawer"
    width="70%"
  >
    <template #title>
      <Icon :icon="getTitle.icon" class="pr-1 m-1" />
      <span> {{ getTitle.value }} </span>
    </template>
    <BasicTable @register="registerTable">
      <template #tableTitle>
        <Icon :icon="getTitle.icon" class="m-1 pr-1" />
        <span> {{ getTitle.value }} </span>
      </template>
    </BasicTable>
  </BasicDrawer>
</template>
<script lang="ts">
  export default defineComponent({
    name: 'ViewsProcessLogPmWatermeterlogList',
  });
</script>
<script lang="ts" setup>
  import { defineComponent, ref, watch } from 'vue';
  import { useI18n } from '/@/hooks/web/useI18n';
  import { useMessage } from '/@/hooks/web/useMessage';
  import { router } from '/@/router';
  import { Icon } from '/@/components/Icon';
  import { BasicTable, BasicColumn, useTable } from '/@/components/Table';
  import { pmWatermeterOAProgressListData } from '/@/api/process/job/pmConnectwaterjob';
  import { useDrawer, BasicDrawer, useDrawerInner } from '/@/components/Drawer';
  import { FormProps } from '/@/components/Form';

  const projectno = ref('');

  const { t } = useI18n('process.log.pmWatermeterlog');
  const { showMessage } = useMessage();
  const getTitle = {
    icon: router.currentRoute.value.meta.icon || 'ant-design:book-outlined',
    value: t('OA申请进度查看'),
  };

  const searchForm: FormProps = {
    baseColProps: { lg: 6, md: 8 },
    labelWidth: 90,
    schemas: [],
  };

  const tableColumns: BasicColumn[] = [
    {
      title: t('项目编号'),
      dataIndex: 'projectno',
      key: 'a.projectno',
      sorter: true,
      width: 100,
      align: 'left',
    },
    {
      title: t('工程名称'),
      dataIndex: 'projInfo.projectname',
      key: 'a.projectno',
      sorter: true,
      width: 200,
      align: 'left',
      // ifShow:false
    },
    {
      title: t('操作时间'),
      dataIndex: 'logtime',
      key: 'a.logtime',
      sorter: true,
      width: 130,
      align: 'center',
    },

    {
      title: t('操作人'),
      dataIndex: 'duser',
      key: 'a.duser',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('操作内容'),
      dataIndex: 'devent',
      key: 'a.devent',
      sorter: true,
      width: 200,
      align: 'left',
    },
    {
      title: t('操作类型'),
      dataIndex: 'dtype',
      key: 'a.dtype',
      sorter: true,
      width: 130,
      align: 'center',
      dictType: 'zf_waterLog_operType',
    },
  ];

  const actionColumn: BasicColumn = {
    width: 160,
    actions: (record: Recordable) => [
      // {
      //   icon: 'clarity:note-edit-line',
      //   title: t('编辑表务日志'),
      //   onClick: handleForm.bind(this, { id: record.id }),
      //   auth: 'process:log:pmWatermeterlog:edit',
      // },
    ],
  };

  const [registerDrawer, { openDrawer }] = useDrawerInner(async (record: any) => {
    projectno.value = record.projectno;
    console.log(record, 'record');
  });

  const [registerTable, { reload }] = useTable({
    api: pmWatermeterOAProgressListData,
    beforeFetch: (params) => {
      params.projectno = projectno.value;
      console.log(params, 'params');
      return params;
    },
    columns: tableColumns,
    // actionColumn: actionColumn,
    formConfig: searchForm,
    showTableSetting: true,
    // useSearchForm: true,
    canResize: true,
  });

  watch(
    () => projectno.value,
    () => {
      reload();
    },
  );
</script>
